local file = "tools.hotfix.lua"
local newc = require("newc")
local cache = newc(file, "cache")
---需要热更新的模块
function reload(modle)
    local obj = require(modle)
    cache[modle] = obj
    return obj
end

---必须再reload之后加载
local objecs = reload("global.objecs")
---重置所有模块
function resert()
    ---清理
    for k, _ in pairs(cache) do
        package.loaded[k] = nil
    end

    ---加载
    for k, _ in pairs(cache) do
        reload(k)
    end

    ---执行完整的gc
    collectgarbage("collect")

    ---热更
    for obj in pairs(objecs) do
        obj:reload()
    end
end

cache.hotfix = {
    reload = reload,
    resert = resert
}
return cache.hotfix
